package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.PropertyWarehouse;
import com.ruoyi.system.service.IPropertyWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;

/**
 * 资产仓库管理Controller
 * 
 * @author ruoyi
 * @date 2023-02-08
 */
@RestController
@RequestMapping("/system/warehouse")
public class PropertyWarehouseController extends BaseController
{
    @Autowired
    private IPropertyWarehouseService propertyWarehouseService;

    /**
     * 查询资产仓库管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PropertyWarehouse propertyWarehouse)
    {
        startPage();
        List<PropertyWarehouse> list = propertyWarehouseService.selectPropertyWarehouseList(propertyWarehouse);
        return getDataTable(list);
    }

    /**
     * 查询资产仓库List
     */
    @GetMapping("/toList")
    public List<PropertyWarehouse> toList(PropertyWarehouse propertyWarehouse)
    {
        List<PropertyWarehouse> list = propertyWarehouseService.selectPropertyWarehouseList(propertyWarehouse);
        return list;
    }

    /**
     * 导出资产仓库管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse:export')")
    @Log(title = "资产仓库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyWarehouse propertyWarehouse)
    {
        List<PropertyWarehouse> list = propertyWarehouseService.selectPropertyWarehouseList(propertyWarehouse);
        ExcelUtil<PropertyWarehouse> util = new ExcelUtil<PropertyWarehouse>(PropertyWarehouse.class);
        util.exportExcel(response, list, "资产仓库管理数据");
    }

    /**
     * 获取资产仓库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(propertyWarehouseService.selectPropertyWarehouseById(id));
    }

    /**
     * 新增资产仓库管理
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse:add')")
    @Log(title = "资产仓库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyWarehouse propertyWarehouse)
    {
        return toAjax(propertyWarehouseService.insertPropertyWarehouse(propertyWarehouse));
    }

    /**
     * 修改资产仓库管理
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse:edit')")
    @Log(title = "资产仓库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyWarehouse propertyWarehouse)
    {
        return toAjax(propertyWarehouseService.updatePropertyWarehouse(propertyWarehouse));
    }

    /**
     * 删除资产仓库管理
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse:remove')")
    @Log(title = "资产仓库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(propertyWarehouseService.deletePropertyWarehouseByIds(ids));
    }
}
